<template>
	<div>
		<el-container>
			<el-header style="background-color: #4a4c5b;">
				<el-row style="float: left;">
					<el-col :span="1/2"> <img src="../../assets/icon/logo.png" style="margin: 10px auto;"></el-col>
					<el-col :span="4"> <span style="font-size: 25px;color: #FFFFFF;margin-left: 20px;line-height: 60px;white-space: nowrap;"><b>新职通</b></span></el-col>
				</el-row>
			</el-header>
			<el-main class="loginmainbox" style="padding-top: 20px;">
				<el-tabs type="border-card" class="loginbox">
					<el-form :model="form" status-icon :rules="rules" ref="form" >
						<!-- <div style="height:40px;text-align:center;margin:20px;"><span style="color:#409EFF;font-size:18px;">邮箱登录</span></div> -->
						<el-form-item  prop="email" >
							<el-input placeholder="请输入您的邮箱" v-model="form.email"></el-input>
						</el-form-item>
						<el-form-item  prop="password" >
						<el-input placeholder="请输入您的密码" v-model="form.password" show-password @keyup.enter.native = 'mmlogin'></el-input>
						</el-form-item>
						<el-form-item>
							<el-button type="primary" style="border: 0px;width: 100%;margin-top: 20px;line-height: 30px;color:#ffffff;" @click="mmlogin">登录</el-button>
						</el-form-item>
					</el-form>
						<el-row>
							<el-col :span="12">
								<div style="float: left;color: #a2999e;line-height: 30px;">
									<span class="pointer"  @click="$router.push('/companyPage/regist')">注册</span>
								</div>
							</el-col>
							<el-col :span="12">
								<div style="float: right;color: #a2999e;line-height: 30px;">
									<span class="pointer" @click="$router.push('/companyPage/forget')">忘记密码？</span>
								</div>
							</el-col>
						</el-row>
				</el-tabs>
			</el-main>
			<el-footer style="text-align: center;width: 100%;white-space: nowrap;color: #A7A7A7;font-size: 10px;line-height: 60px;">
				<div>www. xinzhitong. com版权所有新职通一新时期务工人员转 型升级助推者备案号粤ICP备10054973号-5</div>
			</el-footer>
		</el-container>
	</div>
</template>

<script>
	
	export default {
		data() {
			return {
				username: '',
				yzm:'',
				form:{
                email:'',
                password:'',
            	},
            rules:{
                email:[
                    {
                         required: true,message: '请输入邮箱', trigger: 'blur'
                    }
                ],
               password:[
                    {
                         required: true,message: '请输入密码', trigger: 'blur'
                    }
                ],
            },
				showtime:false,
				count:'',
			}
		},
		methods: {
			mmlogin(){
				 this.$refs['form'].validate((valid) => {
                    if (valid) {
                        var data={
							username:this.form.email,
							password:this.form.password,
                    	}
                    	var URL='http://47.101.180.43:8075/user/login'
                        this.$ajax({
                            method:'post',
                            url:URL,
                            data:data,
                        }).then(response=>{
                            console.log(response.data);
                            var code=response.data.code;
                            if(code==0){
                                console.log(response.data.data); 
                            	this.$router.push('/companyPage/home/selfinfo')
                            }else{
                               	console.log(response.data.msg); 
								this.$notify.error({
									message:'邮箱或密码错误'
								});
                            }
                        }).catch(error=>{
                            console.log(error);
                        })

                } else {
                    console.log('error submit!!');
                }
            });
			},
		},
		mounted() {
			var body = document.getElementsByClassName('loginmainbox')[0]
			console.log(body)
			var height = document.documentElement.clientHeight - 120
			console.log(height.toString() + 'px')
			if(height<=700)
				height=700
			body.style.height = height.toString() + 'px'
			console.log(body.style.height)
	
		

		}
	}
</script>

<style>
	.pointer{
		cursor: pointer;
	}
	.loginmainbox {

		background-image: url(../../assets/loginbgi.jpg);
		background-size: cover;
	}

	.loginbox {
		width: 500px;
		margin-top: 10%;
		margin-left: 60%;
	
	}

	.loginbox .el-tabs__item {
		width: 250px;
		text-align: center;
		font-size: 17px;
		line-height: 60px;
		height: auto;
	}
</style>
